package cn.lger.dao;

import cn.lger.dao.base.BaseDao;
import cn.lger.pojo.Article;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Code that Changed the World
 *
 * @author Pro
 * @date 2018-06-14.
 */
public interface ArticleDao extends BaseDao<Article, Integer> {

    /**
     * 根据条件获取所有数据数量
     * @param userId userId
     * @param categoryId categoryId
     * @return int
     */
    int getTotal(@Param("userId") Integer userId,
                 @Param("categoryId") Integer categoryId);

    /**
     * 根据条件查找多条文章
     * @param userId userId
     * @param categoryId categoryId
     * @param page page
     * @param size siez
     * @return int
     */
    List<Article> findByCondition(@Param("userId") Integer userId,
                                  @Param("categoryId") Integer categoryId,
                                  @Param("page") int page, @Param("size") int size);

    /**
     * 根据userId、articleId查找Article
     * @param userId userId
     * @param articleId articleId
     * @return Article
     */
    Article findOneByArticleIdAndUserId(@Param("userId") int userId,@Param("id") int articleId);

}
